/ Assembly List / LJCTextDataReaderLib / TextDataReader / Read

Namespace - LJCTextDataReaderLib


Returns

true if read successfully; otherwise, false.

Syntax

C#
public Boolean Read()

Reads the next line of the text file. (DE)

Remarks

This is a minimum required method.

Example

C#
// File Contents
// FirstName, LastName
// John, Doe
// Jane, Doe
        
using LJCTextDataReaderLib;

// The hasHeadingLine defaults to true if the parameter is not included.
TextDataReader textReader = new TextDataReader();

// The field delimiter defaults to "," if the parameter is not included.
textReader.LJCSetFile("InputFileSpec.txt");

while(textReader.Read())
{
    // Get the current line values by index.
    for int index = 0; index < textReader.FieldCount; index++)
    {
        object fieldValue = textReader[index];
        string text = textReader.GetString(index);
    }

    // Get the current line values by name.
    foreach string fieldName in textReader.LJCGetFieldNames())
    {
        object fieldValue = textReader[fieldName];
        string text = textReader.GetString(fieldName);
    }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.